import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)

export default new Vuex.Store({
  state:{
    count : 0,
    token : null,
    college_id : 0,
    goodpeople:{},
    power : -1
  },
  mutations:{
    add(state,count){
      state.count += count
    },
    setToken(state,token){
      state.token = token
    },
    setCollegeId(state,college_id){
      state.college_id = college_id
    },
    setGoodPeople(state,goodpeople){
      state.goodpeople = goodpeople
    },
    setPower(state,power){
      state.power = power
    }
  },
  getters:{
    getCount(state){
      return state.count
    },
    getToken(state){
      return state.token
    },
    getCollegeId(state){
      return state.college_id
      //return "1"
    },
    getGoodPeople(state){
      return state.goodpeople
    },
    getPower(state){
      return state.power
    }
  },
  plugins:[createPersistedState({
    storage: window.sessionStorage
  })]
})
